<?php
class mlistcontent extends CI_Model{
	var $listcontent = "list_content";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_list,$id_submenu,$title_list,$date_list,$enable_list)
	{
		$this->id_list= $id_list;
		$this->id_submenu= $id_submenu;
		$this->title_list= $title_list;
		$this->date_list= $date_list;
		$this->enable_list= $enable_list;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->listcontent, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->listcontent);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_list'=>$this->id_list,
			'id_submenu'=>$this->id_submenu,
			'title_list'=>$this->title_list,
			'date_list'=>$this->date_list,
			'enable_list'=>$this->enable_list
		);
		return $this->db->insert($this->listcontent, $arrayData);
	}
	
	function update($id_list)
	{
		$arrayData = array(
			'id_submenu'=>$this->id_submenu,
			'title_list'=>$this->title_list,
			'date_list'=>$this->date_list,
			'enable_list'=>$this->enable_list
		);
		$this->db->where('id_list', $id_list);
		return $this->db->update($this->listcontent, $arrayData);
	}
        
	function remove($id_list)
	{
		$this->db->where('id_list', $id_list);
		return $this->db->delete($this->listcontent);
	}	
	
	function detail($id_list)
	{
		$this->db->where('id_list', $id_list);
		$query = $this->db->get($this->listcontent);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('title_list',$name);
		$query = $this->db->get($this->listcontent);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
}
?>